//
//  URLString.swift
//  TinyShopKeeper_Swift
//
//  Created by huangtao on 16/5/17.
//  Copyright © 2016年 fish. All rights reserved.
//

import Foundation
//接口相同部分
let BASE_URL = "http://service.icloudmatrix.com/service"

//登陆url
let LOGIN_URL = "/user/login"

//时段总收入主图请求url
let TIME_INCOME_MAIN_URL = "/apporder_statistical/main_figure"
//时段总收入子图请求url
let TIME_INCOME_SUB_URL = "/apporder_statistical/subgraph"

//日常运营主图请求url
let DAILY_ANALYSIS_MAIN_URL = "/appdaily_analysis/main_figure"
//日常运营子图请求url
let DAILY_ANALYSIS_SUB_URL = "/appdaily_analysis/subgraph"

//商品运营主图请求url
let PRODUCT_ANALYSIS_MAIN_URL = "/appproduct_analysis/main_figure"
//商品运营子图请求url
let PRODUCT_ANALYSIS_SUB_URL = "/appproduct_analysis/subgraph"

//会员列表请求url
let VIP_LIST_URL = "/appvip_consumption/list"
//会员详细订单列表请求url
let VIP_DETAIL_LIST_URL = "/appvip_consumption/detailed_orders"

//历史记录列表请求url
let HISTORY_RECORD_LIST_URL = "/apphistorical_record/list"
//堂食和外卖列表请求url
let CANTENN_TAKEOUT_LIST_URL = "/apphistorical_record/take_eat"
//订单详细记录请求url
let ORDER_DETAIL_LIST_URL = "/apphistorical_record/detailed_history"

//拼接接口地址
public func baseURLAppend(urlString:String) -> String{
    var str:String = BASE_URL
    str.appendContentsOf(urlString)
    return str
}


//登录参数
public func loginParams() -> [String:String]
{
    let dic = ["client_type":"ios","client_version":"2.0","client_token":"2a8242f0858bbbde9c5dcbd0a0008e5a"]
    return dic
    
}

//拼接的方法
func urlAppendGetParams(urlString:String) ->String{
    //get参数
    //url = 接口地址 + ？ + get参数
    return urlString + "?" + getParamsStr()
}




//公共参数
/*
public func publicParams() -> [String:String]
{
    let dic = ["client_type":"ios","client_version":"2.0","client_token":"2a8242f0858bbbde9c5dcbd0a0008e5a","shop_id":(MZUserInfo.userInfo.userShop?.shop_account)!,"mgr_base_id":MZUserInfo.userInfo.mgrBaseId!,"access_token":MZUserInfo.userInfo.accessToken!]
    return dic
}*/



//网络请求用于Memberinformation
func getParamsStr() -> String{
    
    var str = "client_type=ios"
    str += "&client_version=2.0"
    str += "&client_token=2a8242f0858bbbde9c5dcbd0a0008e5a"
    str += "&shop_id=" + (UserInfo.userShop?.shop_id)!
    print((UserInfo.mgrBaseId))
    str += "&mgr_base_id=" + (UserInfo.mgrBaseId)!
    str += "&access_token=" + (UserInfo.accessToken!)
    str += "&mac_code=" + ""
    
    let desStr = str + "&key=" + str.md5String()
    
    return desStr
}


//1、	client_type： 客户端类型，固定取值为：android、ios、web_admin
//2、	client_version：客户端版本号，固定为:2.0
//3、	client_token：客户端公共访问令牌，测试令牌为2a8242f0858bbbde9c5dcbd0a0008e5a
//4、	shop_id：当前已登录店铺id，唯一
//5、	mgr_base_id：当前已登录店铺员工id，唯一
//6、	access_token：当前已登录员工的授权访问令牌
//7、	mac_code：发出服务请求的客户端mac地址，mac地址可为空
//8、	key：验签密钥，验签密钥是指将1-7项参数名及字符串以=连接构成的字符串使用md5加密所得到的32位密钥











